package cn.yunyichina.provider.base.service.impl;

import cn.yunyichina.provider.base.dao.DoctorDao;
import cn.yunyichina.provider.base.entity.Doctor;
import cn.yunyichina.provider.base.vo.CheckWardsAccount;
import cn.yunyichina.provider.base.vo.LoginWardsRequest;
import cn.yunyichina.provider.base.vo.WardsBindMobileRequest;
import cn.yunyichina.provider.base.vo.WardsRequest;
import cn.yunyichina.provider.framework.annotation.validate.ValidateException;
import cn.yunyichina.provider.framework.annotation.validate.Validator;
import cn.yunyichina.provider.framework.common.PKGenerator;
import cn.yunyichina.provider.framework.data.SpringContextHandler;
import cn.yunyichina.provider.framework.dubbo.service.BaseService;
import cn.yunyichina.provider.framework.dubbo.service.CacheService;
import cn.yunyichina.provider.framework.dubbo.service.HisifaceService;
import cn.yunyichina.provider.framework.dubbo.service.MessageService;
import cn.yunyichina.provider.framework.exception.CallException;
import cn.yunyichina.provider.iface.entity.base.Org;
import cn.yunyichina.provider.iface.entity.common.ResCommon;
import cn.yunyichina.provider.iface.entity.common.Response;
import cn.yunyichina.provider.iface.entity.common.ResponseObject;
import cn.yunyichina.provider.iface.entity.hisiface.other.HospitalReportVo;
import cn.yunyichina.provider.iface.entity.hisiface.other.HospitalReportVoResponse;
import cn.yunyichina.provider.iface.entity.hisiface.wards.*;
import cn.yunyichina.utils.commons.DateUtils;
import cn.yunyichina.utils.convert.JsonUtils;
import com.alibaba.dubbo.common.utils.CollectionUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

/**
 * 接口分类
 */
@Service("wardsServiceImpl")
public class WardsServiceImpl {
    private static final Logger logger = LoggerFactory.getLogger(WardsServiceImpl.class);

    @Autowired
    private DoctorDao doctorDao;

    private static final String NO_DATA_MSG = "执行成功但没有对应数据";
    private static final String NO_DATA_CODE = "1004";

    private static final String FAIL_MSG = "执行失败";
    private static final String FAIL_CODE = "1003";

    /**
     * yyt.base.wards.Account.isduplicate.check
     * 校验登录账号跟密码是否对应多加医院
     *
     * @param data
     * @return
     */
    public ResponseObject checkWardsAccountIsduplicate(String data) {
        logger.info("移动查房=》checkWardsAccountIsduplicate 请求入参 data={}", data);
        ResponseObject response = new ResponseObject();
        CheckWardsAccount request = JsonUtils.parseObject(data, CheckWardsAccount.class);
        //检查参数合法性
        try {
            Validator.getInstance().validate(request);
        } catch (ValidateException ex) {
            logger.info(" 数据校验失败:" + ex.getMessage() + "|入参:" + data + "！");
            logger.error("error", ex);
            response.setResultCodeAndMessage("1002", "数据校验失败:" + ex.getMessage() + "！");
            return response;
        }
        try {
            Doctor doctor = new Doctor();
            doctor.setPassword(request.getPassword());
            doctor.setDoctorCode(request.getDoctorCode());
            List<Doctor> dbDoctorList = doctorDao.select(doctor);
            logger.info("移动查房=》checkWardsAccountIsduplicate 查询数据库返回 dbDoctorList ={}", new Object[]{JsonUtils.toJsonString(dbDoctorList)});
            Map<String, Map<String, String>> resultMap = new HashMap<>();
            List<Map<String, String>> resultList = new ArrayList<>();
            if (CollectionUtils.isEmpty(dbDoctorList)) {
                response.setResultCodeAndMessageAndResult("0", "成功", resultList);
                return response;
            }
            for (Doctor doc : dbDoctorList) {
                StringBuilder builder = new StringBuilder();
                Map<String, String> hospitalInfo = new HashMap<>();
                hospitalInfo.put("hospitalCode", doc.getHospitalCode());
                hospitalInfo.put("hospitalName", doc.getHospitalName());
                resultMap.put(builder.append(doc.getHospitalCode()).append(doc.getDoctorCode()).toString(), hospitalInfo);
            }

            for (String resultKey : resultMap.keySet()) {
                resultList.add(resultMap.get(resultKey));
            }
            response.setResultCodeAndMessageAndResult("0", "成功", resultList);
            logger.info("移动查房=》checkWardsAccountIsduplicate 返回出参 response={}", new Object[]{JsonUtils.toJsonString(response)});
            return response;
        } catch (Exception e) {
            logger.error("checkWardsAccountIsduplicate errMsg={}", e);
            response.setResultCodeAndMessage("0", "失败");
            return response;
        }
    }


    /*
    移动查房医生端登录接口
    yyt.base.wards.login
     */
    public ResponseObject loginWards(String data) {
        logger.info("移动查房=》loginWards 请求入参 data ={}", data);
        ResponseObject response = new ResponseObject();
        LoginWardsRequest request = JsonUtils.parseObject(data, LoginWardsRequest.class);

        //检查参数合法性
        try {
            Validator.getInstance().validate(request);
        } catch (ValidateException ex) {
            logger.info(" 数据校验失败:" + ex.getMessage() + "|入参:" + data + "！");
            logger.error("error", ex);
            response.setResultCodeAndMessage("1002", "数据校验失败:" + ex.getMessage() + "！");
            return response;
        }

        List<Doctor> dbDoctorList = doctorDao.selectDoctorByDoctorAndPwd(request.getDoctorCode(), request.getPassword(), request.getHospitalCode());
        logger.info("移动查房=》通过医生代码，密码，医院代码查询 医生表返回数据 dbDoctorList ={}", new Object[]{JsonUtils.toJsonString(dbDoctorList)});
        if (request.getHospitalCode().contains("jmsxhq") || request.getHospitalCode().contains("hpxrmyy") || request.getHospitalCode().contains("gzszcqrmyy") || request.getHospitalCode().contains("lpxrmyy") || request.getHospitalCode().contains("fgrmyy")) {
            logger.info("只查数据库");
            if (CollectionUtils.isEmpty(dbDoctorList)) {
                response.setResultCodeAndMessage(NO_DATA_CODE, NO_DATA_MSG);
                return response;
            }
            Doctor returnDoctor = getDoctor(request);
            response.setResultCodeAndMessageAndResult("0", "成功", returnDoctor);
            logger.info("移动查房=》医生登录不走his医生接口返回  response ={}", new Object[]{JsonUtils.toJsonString(response)});
            return response;
        } else {

            DoctorListVo requestHis = new DoctorListVo();
            requestHis.setHospitalCode(request.getHospitalCode());
            requestHis.setDoctorCode(request.getDoctorCode());
            logger.info("查询his医生接口入参 requestHis ={}", new Object[]{JsonUtils.toJsonString(requestHis)});
            ResCommon<List<DoctorListVoResponse>> hisResponse = HisifaceService.getHisifaceClient().getDoctorList(requestHis);
            logger.info("查询his医生接口返回 hisResponse ={}", new Object[]{JsonUtils.toJsonString(hisResponse)});
            List<DoctorListVoResponse> doctorResponseList = hisResponse.getResult();
            String hisResultCode = hisResponse.getResultCode();


            // 查询组织信息-----------------------------------------------start
            Map<String, String> orgParamMap = new HashMap<String, String>();
            orgParamMap.put("org_code", request.getHospitalCode());
            logger.info("【医生列表-查询组织信息】, yyt.base.branchhospital.org.list request=" + JSON.toJSONString(orgParamMap));
            Response orgResponse = BaseService.callUnderlineFromInternal("yyt.base.branchhospital.org.list", JSON.toJSONString(orgParamMap));
            logger.info("【医生列表-查询组织信息】, yyt.base.branchhospital.org.list response=" + JSONObject.toJSONString(orgResponse));
            if (!"0".equals(orgResponse.getResultCode())) {
                throw new CallException("1003", "找不到机构信息 by org_code=" + request.getHospitalCode());
            }
            List<Org> orgList = JsonUtils.parseArray(orgResponse.getResult(), Org.class);
            if (org.springframework.util.CollectionUtils.isEmpty(orgList)) {
                throw new CallException("1004", "找不到机构信息 by org_code=" + request.getHospitalCode());
            }

            Org org = orgList.get(0);

            if (CollectionUtils.isEmpty(dbDoctorList)) {
                //数据库中没有存在过该工号医生，或者 是用户输入密码错误找不到信息，也可能是医生在his 系统
                //更新了密码然后输入新密码导致跟旧密码不一致

                if (!ResCommon.SUCCESS_CODE.equals(hisResultCode)) {
                    response.setResultCodeAndMessage(FAIL_CODE, hisResponse.getResultMessage());
                } else {
                    //返回医生列表
                    if (CollectionUtils.isNotEmpty(doctorResponseList)) {
                        logger.info("移动查房==》his 返回成功返回的医生列表 doctorResponseList={} ", new Object[]{doctorResponseList});
                        //进一步确认该工号是否存在数据库
                        DoctorDao doctorDao = SpringContextHandler.getBean(DoctorDao.class);
                        List<Doctor> dbDoctors = doctorDao.selectByHospitalCodeAndDoctorCode(request.getHospitalCode(), request.getDoctorCode());
                        //需要保存his 返回的数据
                        if (CollectionUtils.isEmpty(dbDoctors)) {
                            logger.info("移动查房==》新增医生信息");
                            //该工号之前没有存在数据库中需要保存
                            List<Doctor> needToSaveDoctors = new ArrayList<>();
                            for (DoctorListVoResponse doc : doctorResponseList) {
                                if (!request.getDoctorCode().equals(doc.getDoctorCode())) {
                                    response.setResultCodeAndMessage("1004", "his 返回的医生工号，同输入的工号不一致");
                                    return response;
                                }
                                Doctor hisDoctor = buildDoctor(org, doc);
                                needToSaveDoctors.add(hisDoctor);
                            }

                            doctorDao.batchInsert(needToSaveDoctors);
                            Doctor returnDoctor = getDoctor(request);
                            response.setResultCodeAndMessageAndResult("0", "成功", returnDoctor);
                            logger.info("移动查房 =》登录接口返回response ={}", new Object[]{JsonUtils.toJsonString(response)});
                        } else {
                            logger.info("移动查房==》更新医生信息");
                            //改工号之前已经存在数据库中，只是密码跟库中的密码不一致
                            //确认是否是因为医生在his 更改密码导致，还是因为真正输入错误密码
                            for (DoctorListVoResponse doc : doctorResponseList) {
                                if (!request.getDoctorCode().equals(doc.getDoctorCode())) {
                                    response.setResultCodeAndMessage("1004", "his 返回的医生工号，同输入的工号不一致");
                                    return response;
                                }
                            }
                            if (request.getPassword().equals(doctorResponseList.get(0).getPassword())) {
                                //进入更改密码
                                updateDoctor(doctorResponseList, org, doctorDao, dbDoctors);

                                Doctor returnDoctor = getDoctor(request);
                                logger.info("");
                                response.setResultCodeAndMessageAndResult("0", "成功", returnDoctor);
                                logger.info("移动查房=》登录接口返回 response ={}", new Object[]{JsonUtils.toJsonString(response)});
                            } else {
                                response.setResultCodeAndMessage("1004", "密码或者工号错误");
                            }
                        }
                    } else {
                        //his根本没有该工号
                        response.setResultCodeAndMessage(NO_DATA_CODE, NO_DATA_MSG);
                    }
                }
            } else {

                if (!ResCommon.SUCCESS_CODE.equals(hisResultCode)) {
                    response.setResultCodeAndMessage(FAIL_CODE, hisResponse.getResultMessage());
                } else {
                    updateDoctor(doctorResponseList, org, doctorDao, dbDoctorList);
                    Doctor returnDoctor = getDoctor(request);
                    response.setResultCodeAndMessageAndResult("0", "成功", returnDoctor);
                    logger.info("移动查房=》 返回 response={}", new Object[]{JsonUtils.toJsonString(response)});
                }

            }

            return response;

        }
    }

    private Doctor getDoctor(LoginWardsRequest request) {
        logger.info("移动查房==》查询数据库 组装数据返回给前端");
        List<Doctor> returnDoctors = doctorDao.selectByHospitalCodeAndDoctorCode(request.getHospitalCode(), request.getDoctorCode());
        Doctor returnDoctor = returnDoctors.get(0);

        StringBuilder deptCodeBuilder = new StringBuilder();
        StringBuilder deptNameBuilder = new StringBuilder();
        StringBuilder permissionBuilder = new StringBuilder();
        for (Doctor doc : returnDoctors) {
            //权限拼接
            if (doc.getPermission() != null) {
                permissionBuilder.append(doc.getDepartmentId()).append(",");
            }
            deptNameBuilder.append(doc.getDepartmentName()).append(",");
            deptCodeBuilder.append(doc.getDepartmentId()).append(",");
        }

        String deptName = deptNameBuilder.toString();
        String permission = permissionBuilder.toString();
        String deptCode = deptCodeBuilder.toString();
        returnDoctor.setDepartmentName(deptName);
        returnDoctor.setPermission(permission);
        returnDoctor.setDepartmentId(deptCode);
        return returnDoctor;
    }


    private void updateDoctor(List<DoctorListVoResponse> doctorResponseList, Org org, DoctorDao doctorDao, List<Doctor> dbDoctors) {
        Map<String, Doctor> dbDoctorMap = new HashMap<>();
        Map<String, Doctor> hisDoctorMap = new HashMap<>();

        for (Doctor doc : dbDoctors) {
            dbDoctorMap.put(doc.getDepartmentName() + "_" + doc.getDoctorCode(), doc);
        }

        for (DoctorListVoResponse doc : doctorResponseList) {
            Doctor hisDoctor = buildDoctor(org, doc);
            hisDoctorMap.put(hisDoctor.getDepartmentName() + "_" + hisDoctor.getDoctorCode(), hisDoctor);
        }

        List<Doctor> needToSaveDoctors = new ArrayList<>();
        List<Doctor> needToUpdteDoctors = new ArrayList<>();

        for (String deptDoctorCode : hisDoctorMap.keySet()) {
            if (dbDoctorMap.get(deptDoctorCode) != null) {
                Doctor doctor = dbDoctorMap.get(deptDoctorCode);
                doctor.setDepartmentId(hisDoctorMap.get(deptDoctorCode).getDepartmentId());
                doctor.setPassword(hisDoctorMap.get(deptDoctorCode).getPassword());
                needToUpdteDoctors.add(doctor);
            } else {
                needToSaveDoctors.add(hisDoctorMap.get(deptDoctorCode));
            }
        }

        if (CollectionUtils.isNotEmpty(needToSaveDoctors)) {
            doctorDao.batchInsert(needToSaveDoctors);
        }

        if (CollectionUtils.isNotEmpty(needToUpdteDoctors)) {
            for (Doctor doc : needToUpdteDoctors) {
                doctorDao.update(doc);
            }
        }
    }

    private Doctor buildDoctor(Org org, DoctorListVoResponse vo) {
        Doctor doctor = new Doctor();
        doctor.setId(PKGenerator.generateId());
        doctor.setName(vo.getDoctorName());
        doctor.setDepartmentId(vo.getDeptCode());
        doctor.setDepartmentName(vo.getDeptName());
        doctor.setHospitalId(org.getId());
        doctor.setHospitalCode(org.getOrgCode());
        doctor.setHospitalName(org.getOrgName());
        doctor.setBranchId("");
        doctor.setBranchName("");
        // doctor.setTitle();
        doctor.setImg(vo.getDoctorPic());
        doctor.setMobile(vo.getDoctorMobile());
        doctor.setIdNo("");
        if (com.alibaba.dubbo.common.utils.StringUtils.isBlank(vo.getDoctorBirth())) {
            doctor.setBirth(DateUtils.dateToString(new Date()));
        } else {
            doctor.setBirth(vo.getDoctorBirth());
        }

        doctor.setSex(Integer.parseInt(vo.getDoctorSex()));

        doctor.setNumber("");
        doctor.setDisc(vo.getDoctorIntrodution());
        doctor.setSkilled(vo.getDoctorSkill());
        // doctor.setStatus();
        doctor.setCardNo("");
        doctor.setMedicalcardNo("");
        doctor.setDoctorCode(vo.getDoctorCode());
        doctor.setRatio("");
//        doctor.setEntryTime("");
//        doctor.setRetirementTime("");
//        doctor.setDepartureTime("");
//        doctor.setDeathTime("");
//        doctor.setLossTime("");
        doctor.setCreatedTime(DateUtils.dateToString(new Date()));
        doctor.setUpdateTime(DateUtils.dateToString(new Date()));
        //doctor.setDelStatus();
        doctor.setPassword(vo.getPassword());
        return doctor;
    }


    /*
       获取医生信息
       yyt.base.wards.doctor.get
     */
    public ResponseObject getWardsDoctor(String data) {
        ResponseObject response = new ResponseObject();
        List<DoctorListVoResponse> doctorListVoResponse = null;

        try {
            WardsRequest request = JsonUtils.parseObject(data, WardsRequest.class);

            if (StringUtils.isBlank(request.getHospitalCode())) {
                response.setResultCodeAndMessage("1002", "数据校验失败 hospitalCode不能为空！");
                return response;
            }

            DoctorListVo requestHis = new DoctorListVo();
            requestHis.setHospitalCode(request.getHospitalCode());
            requestHis.setDeptCode(request.getDeptCode());
            requestHis.setDoctorCode(request.getDoctorCode());
            requestHis.setBeginDate(request.getBeginDate());
            requestHis.setEndDate(request.getEndDate());
            ResCommon<List<DoctorListVoResponse>> hisResponse = HisifaceService.getHisifaceClient().getDoctorList(requestHis);

            if (!ResCommon.SUCCESS_CODE.equals(hisResponse.getResultCode())) {
                response.setResultCodeAndMessage(FAIL_CODE, hisResponse.getResultMessage());
            } else {
                //返回医生列表
                if (CollectionUtils.isNotEmpty(hisResponse.getResult())) {
                    doctorListVoResponse = hisResponse.getResult();
                    response.setResultCodeAndMessageAndResult("0", "成功", doctorListVoResponse);

//                    Thread doctorListSave = new Thread(new DoctorListSaveRunnable(doctorListVoResponse,request));
//                    doctorListSave.start();

                } else {
                    response.setResultCodeAndMessage(NO_DATA_CODE, NO_DATA_MSG);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            response.setResultCodeAndMessage("1999", "系统异常 ：" + e.getMessage());
        }


        return response;
    }

    /*
            获取医生的住院病人列表
            yyt.base.wards.patient.list.get
     */
    public ResponseObject getWardsPatientList(String data) {
        logger.info("移动查房=》getWardsPatientList 请求入参 data ={}", data);

        ResponseObject response = new ResponseObject();

        try {
            WardsRequest request = JsonUtils.parseObject(data, WardsRequest.class);

            if (StringUtils.isBlank(request.getHospitalCode())
                    || StringUtils.isBlank(request.getDoctorCode())) {
                response.setResultCodeAndMessage("1002", "数据校验失败 hospitalCode,doctorCode 不能为空！");
                return response;
            }

            ZyPatientListVo requestHis = new ZyPatientListVo();
            requestHis.setHospitalCode(request.getHospitalCode());
            requestHis.setDeptCode(request.getDeptCode());
            requestHis.setDoctorCode(request.getDoctorCode());
            requestHis.setBeginDate(request.getBeginDate());
            requestHis.setEndDate(request.getEndDate());
            logger.info(" 移动查房 getWardsPatientList 请求入参 调度中心入参 requestHis ={}", new Object[]{JsonUtils.toJsonString(requestHis)});

            ResCommon<List<ZyPatientListVoResponse>> hisResponse = HisifaceService.getHisifaceClient().getZyPatientList(requestHis);
            logger.info(" 移动查房 getWardsPatientList  调度中心返回 hisResponse ={}", new Object[]{JsonUtils.toJsonString(hisResponse)});

            if (!ResCommon.SUCCESS_CODE.equals(hisResponse.getResultCode())) {
                response.setResultCodeAndMessage(FAIL_CODE, hisResponse.getResultMessage());
            } else {
                if (CollectionUtils.isNotEmpty(hisResponse.getResult())) {
                    response.setResultCodeAndMessageAndResult("0", "成功", JsonUtils.toJsonString(hisResponse.getResult()));
                } else {
                    response.setResultCodeAndMessage(NO_DATA_CODE, NO_DATA_MSG);
                }
            }

        } catch (Exception e) {
            logger.error("移动查房 getWardsPatHospitalRecord  errMsg ={}", e);
            response.setResultCodeAndMessage("1999", "系统异常 ：" + e.getMessage());
        }

        logger.info(" 移动查房 getWardsPatientList 返回 response ={}", new Object[]{JsonUtils.toJsonString(response)});

        return response;
    }

    /*
    获取指定患者住院信息
    yyt.base.wards.pat.hospital.record.get
     */
    public ResponseObject getWardsPatHospitalRecord(String data) {
        logger.info(" 移动查房 getWardsPatHospitalRecord 请求入参 data ={}", data);
        ResponseObject response = new ResponseObject();
        PatHospitalRecordVoResponse patRecordResponse = null;
        try {
            WardsRequest request = JsonUtils.parseObject(data, WardsRequest.class);
            if (StringUtils.isBlank(request.getHospitalCode())) {
                response.setResultCodeAndMessage("1002", "数据校验失败 hospitalCode不能为空！");
                return response;
            }

            if (StringUtils.isBlank(request.getAdmissionNo())
                    && (StringUtils.isBlank(request.getPatCardNo()) || StringUtils.isBlank(request.getPatCardType()))) {
                response.setResultCodeAndMessage("1002", "数据校验失败 admission_no 同 pat_card_no 和 pat_card_type 不能同时为空！");
                return response;
            }
            PatHospitalRecordVo requestHis = new PatHospitalRecordVo();
            requestHis.setHospitalCode(request.getHospitalCode());
            requestHis.setAdmissionNo(request.getAdmissionNo());
            requestHis.setPatCardType(request.getPatCardType());
            requestHis.setPatCardNo(request.getPatCardNo());
            requestHis.setBeginDate(request.getBeginDate());
            requestHis.setEndDate(request.getEndDate());
            logger.info(" 移动查房 getWardsPatHospitalRecord 请求入参 调度中心入参 requestHis ={}", new Object[]{JsonUtils.toJsonString(requestHis)});

            ResCommon<PatHospitalRecordVoResponse> hisResponse = HisifaceService.getHisifaceClient().getPatHospitalRecord(requestHis);
            logger.info(" 移动查房 getWardsPatHospitalRecord  调度中心返回 hisResponse ={}", new Object[]{JsonUtils.toJsonString(hisResponse)});

            if (!ResCommon.SUCCESS_CODE.equals(hisResponse.getResultCode())) {
                response.setResultCodeAndMessage(FAIL_CODE, hisResponse.getResultMessage());
            } else {
                patRecordResponse = hisResponse.getResult();
                if (patRecordResponse != null) {
                    response.setResultCodeAndMessageAndResult("0", "成功", JsonUtils.toJsonString(patRecordResponse));

                } else {
                    response.setResultCodeAndMessage(NO_DATA_CODE, NO_DATA_MSG);
                }
            }

        } catch (Exception e) {
            logger.error("移动查房 getWardsPatHospitalRecord  errMsg ={}", e);
            response.setResultCodeAndMessage("1999", "系统异常 ：" + e.getMessage());
        }
        logger.info(" 移动查房 getWardsPatHospitalRecord  返回 response ={}", new Object[]{JsonUtils.toJsonString(response)});
        return response;
    }

    /*
    获取医嘱列表
    yyt.base.wards.advice.list.get
     */
    public ResponseObject getWardsAdviceList(String data) {
        logger.info(" 移动查房 getWardsAdviceList 请求入参 data ={}", data);
        ResponseObject response = new ResponseObject();
        AdviceListVoResponse adviceResponse = null;

        try {
            WardsRequest request = JsonUtils.parseObject(data, WardsRequest.class);
            if (StringUtils.isBlank(request.getHospitalCode())) {
                response.setResultCodeAndMessage("1002", "数据校验失败 hospitalCode 不能为空！");
                return response;
            }

            if (StringUtils.isBlank(request.getAdmissionNo()) || StringUtils.isBlank(request.getAdviceType())) {
                response.setResultCodeAndMessage("1002", "数据校验失败 admission_no, advice_type不能为空！");
                return response;
            }
            AdviceListVo requestHis = new AdviceListVo();
            requestHis.setHospitalCode(request.getHospitalCode());
            requestHis.setAdmissionNo(request.getAdmissionNo());
            requestHis.setAdviceType(request.getAdviceType());
            requestHis.setBeginDate(request.getBeginDate());
            requestHis.setEndDate(request.getEndDate());
            logger.info(" 移动查房 getWardsAdviceList 请求入参 调度中心入参 requestHis ={}", new Object[]{JsonUtils.toJsonString(requestHis)});

            ResCommon<AdviceListVoResponse> hisResponse = HisifaceService.getHisifaceClient().getAdviceList(requestHis);
            logger.info(" 移动查房 getWardsAdviceList  调度中心返回 hisResponse ={}", new Object[]{JsonUtils.toJsonString(hisResponse)});

            if (!ResCommon.SUCCESS_CODE.equals(hisResponse.getResultCode())) {
                response.setResultCodeAndMessage(FAIL_CODE, hisResponse.getResultMessage());
            } else {
                adviceResponse = hisResponse.getResult();
                if (adviceResponse != null) {
                    response.setResultCodeAndMessageAndResult("0", "成功", adviceResponse);
                } else {
                    response.setResultCodeAndMessage(NO_DATA_CODE, NO_DATA_MSG);
                }
            }

        } catch (Exception e) {
            logger.info("移动查房 getWardsAdviceList errMsg={}", e);
            response.setResultCodeAndMessage("1999", "系统异常 ：" + e.getMessage());
        }

        logger.info(" 移动查房 getWardsAdviceList  返回 response ={}", new Object[]{JsonUtils.toJsonString(response)});

        return response;
    }

    /*
       获取病历列表
     */
    public ResponseObject getWardsMedRecordList(String data) {
        logger.info(" 移动查房 getWardsMedRecordList 请求入参 data ={}", data);

        ResponseObject response = new ResponseObject();
        MedRecordListVoResponse medRecordListVoResponse = null;
        try {
            WardsRequest request = JsonUtils.parseObject(data, WardsRequest.class);

            if (StringUtils.isBlank(request.getHospitalCode())) {
                response.setResultCodeAndMessage("1002", "数据校验失败 hospitalCode不能为空！");
                return response;
            }

            if (StringUtils.isBlank(request.getAdmissionNo())
                    && (StringUtils.isBlank(request.getPatCardNo()) || StringUtils.isBlank(request.getPatCardType()))) {
                response.setResultCodeAndMessage("1002", "数据校验失败 admission_no , pat_card_no 和 pat_card_type 不能同时为空！");
                return response;
            }
            MedRecordListVo requestHis = new MedRecordListVo();
            requestHis.setHospitalCode(request.getHospitalCode());
            requestHis.setAdmissionNo(request.getAdmissionNo());
            requestHis.setPatCardNo(request.getPatCardNo());
            requestHis.setPatCardType(request.getPatCardType());
            requestHis.setBeginDate(request.getBeginDate());
            requestHis.setEndDate(request.getEndDate());
            logger.info(" 移动查房 getWardsMedRecordList 请求入参 调度中心入参 requestHis ={}", new Object[]{JsonUtils.toJsonString(requestHis)});
            ResCommon<MedRecordListVoResponse> hisResponse = HisifaceService.getHisifaceClient().getMedRecordList(requestHis);
            logger.info(" 移动查房 getWardsMedRecordList  调度中心返回 hisResponse ={}", new Object[]{JsonUtils.toJsonString(hisResponse)});
            if (!ResCommon.SUCCESS_CODE.equals(hisResponse.getResultCode())) {
                response.setResultCodeAndMessage(FAIL_CODE, hisResponse.getResultMessage());
            } else {
                medRecordListVoResponse = hisResponse.getResult();
                if (medRecordListVoResponse != null) {
                    response.setResultCodeAndMessageAndResult("0", "成功", medRecordListVoResponse);
                } else {
                    response.setResultCodeAndMessage(NO_DATA_CODE, NO_DATA_MSG);
                }
            }

        } catch (Exception e) {
            logger.info("移动查房 getWardsMedRecordList errMsg={}", e);
            response.setResultCodeAndMessage("1999", "系统异常 ：" + e.getMessage());
        }
        logger.info(" 移动查房 getWardsMedRecordList  返回 response ={}", new Object[]{JsonUtils.toJsonString(response)});


        return response;
    }

    /*
       获取入院记录
     */
    public ResponseObject getWardsInHospitalRecord(String data) {
        logger.info(" 移动查房 getWardsInHospitalRecord 请求入参 data ={}", data);

        ResponseObject response = new ResponseObject();
        InHospitalRecordVoResponse inHospitalRecordResponse = null;
        try {
            WardsRequest request = JsonUtils.parseObject(data, WardsRequest.class);

            if (StringUtils.isBlank(request.getHospitalCode())
                    || StringUtils.isBlank(request.getRecordId())) {
                response.setResultCodeAndMessage("1002", "数据校验失败 hospitalCode,record_id 不能为空！");
                return response;
            }
            InHospitalRecordVo requestHis = new InHospitalRecordVo();
            requestHis.setHospitalCode(request.getHospitalCode());
            requestHis.setRecordId(request.getRecordId());
            logger.info(" 移动查房 getWardsInHospitalRecord 请求入参 调度中心入参 requestHis ={}", new Object[]{JsonUtils.toJsonString(requestHis)});
            ResCommon<InHospitalRecordVoResponse> hisResponse = HisifaceService.getHisifaceClient().getInHospitalRecord(requestHis);
            logger.info(" 移动查房 getWardsInHospitalRecord  调度中心返回 hisResponse ={}", new Object[]{JsonUtils.toJsonString(hisResponse)});

            if (!ResCommon.SUCCESS_CODE.equals(hisResponse.getResultCode())) {
                response.setResultCodeAndMessage(FAIL_CODE, hisResponse.getResultMessage());
            } else {
                inHospitalRecordResponse = hisResponse.getResult();
                if (inHospitalRecordResponse != null) {
                    response.setResultCodeAndMessageAndResult("0", "成功", inHospitalRecordResponse);
                } else {
                    response.setResultCodeAndMessage(NO_DATA_CODE, NO_DATA_MSG);
                }
            }

        } catch (Exception e) {
            logger.info("移动查房 getWardsInHospitalRecord errMsg={}", e);
            response.setResultCodeAndMessage("1999", "系统异常 ：" + e.getMessage());
        }

        logger.info(" 移动查房 getWardsInHospitalRecord  返回 response ={}", new Object[]{JsonUtils.toJsonString(response)});

        return response;
    }



    /*
    获取病程记录
     */

    public ResponseObject getWardsCourseList(String data) {
        logger.info(" 移动查房 getWardsCourseList 请求入参 data ={}", data);

        ResponseObject response = new ResponseObject();
        CourseListVoResponse courseListVoResponse = null;
        try {
            WardsRequest request = JsonUtils.parseObject(data, WardsRequest.class);

            if (StringUtils.isBlank(request.getHospitalCode())
                    || StringUtils.isBlank(request.getRecordId()) || request.getCourseType() == null) {
                response.setResultCodeAndMessage("1002", "数据校验失败 hospitalCode,record_id 不能为空！");
                return response;
            }
            CourseListVo requestHis = new CourseListVo();
            requestHis.setHospitalCode(request.getHospitalCode());
            requestHis.setRecordId(request.getRecordId());
            requestHis.setCourseType(request.getCourseType());
            logger.info(" 移动查房 getWardsCourseList 请求入参 调度中心入参 requestHis ={}", new Object[]{JsonUtils.toJsonString(requestHis)});
            ResCommon<CourseListVoResponse> hisResponse = HisifaceService.getHisifaceClient().getCourseList(requestHis);
            logger.info(" 移动查房 getWardsCourseList  调度中心返回 hisResponse ={}", new Object[]{JsonUtils.toJsonString(hisResponse)});

            if (!ResCommon.SUCCESS_CODE.equals(hisResponse.getResultCode())) {
                response.setResultCodeAndMessage(FAIL_CODE, hisResponse.getResultMessage());
            } else {
                courseListVoResponse = hisResponse.getResult();
                if (courseListVoResponse != null) {
                    response.setResultCodeAndMessageAndResult("0", "成功", courseListVoResponse);
                } else {
                    response.setResultCodeAndMessage(NO_DATA_CODE, NO_DATA_MSG);
                }
            }
        } catch (Exception e) {
            logger.info("移动查房 getWardsCourseList errMsg={}", e);
            response.setResultCodeAndMessage("1999", "系统异常 ：" + e.getMessage());

        }
        logger.info(" 移动查房 getWardsCourseList  返回 response ={}", new Object[]{JsonUtils.toJsonString(response)});

        return response;
    }


     /*
        获取手术记录
     */

    public ResponseObject getWardsSurgeryRecord(String data) {
        logger.info("移动查房 getWardsSurgeryRecord 请求原始入参 data={}", data);
        ResponseObject response = new ResponseObject();
        SurgeryRecordVoResponse surgeryRecordVoResponse = null;
        try {
            WardsRequest request = JsonUtils.parseObject(data, WardsRequest.class);

            if (StringUtils.isBlank(request.getHospitalCode())
                    || StringUtils.isBlank(request.getRecordId())) {
                response.setResultCodeAndMessage("1002", "数据校验失败 hospitalCode,record_id 不能为空！");
                return response;
            }

            SurgeryRecordVo requestHis = new SurgeryRecordVo();
            requestHis.setHospitalCode(request.getHospitalCode());
            requestHis.setRecordId(request.getRecordId());
            logger.info("移动查房 getWardsSurgeryRecord 请求调度中心入参 requestHis={}", new Object[]{JsonUtils.toJsonString(requestHis)});
            ResCommon<SurgeryRecordVoResponse> hisResponse = HisifaceService.getHisifaceClient().getSurgeryRecord(requestHis);
            logger.info("移动查房 getWardsSurgeryRecord 调度中心出参 hisResponse={}", new Object[]{JsonUtils.toJsonString(hisResponse)});
            if (!ResCommon.SUCCESS_CODE.equals(hisResponse.getResultCode())) {
                response.setResultCodeAndMessage(FAIL_CODE, hisResponse.getResultMessage());
            } else {
                surgeryRecordVoResponse = hisResponse.getResult();
                if (surgeryRecordVoResponse != null) {
                    response.setResultCodeAndMessageAndResult("0", "成功", surgeryRecordVoResponse);
                } else {
                    response.setResultCodeAndMessage(NO_DATA_CODE, NO_DATA_MSG);
                }
            }

        } catch (Exception e) {
            logger.info("移动查房 getWardsSurgeryRecord errMsg={}", e);
            response.setResultCodeAndMessage("1999", "系统异常 ：" + e.getMessage());
        }
        logger.info("移动查房 getWardsSurgeryRecord 返回 response={}", new Object[]{JsonUtils.toJsonString(response)});
        return response;
    }


     /*
       获取术前小结
     */

    public ResponseObject getWardsPreSurgeryRecord(String data) {
        logger.info("移动查房 getWardsPreSurgeryRecord 请求原始入参 data={}", data);
        ResponseObject response = new ResponseObject();
        PreSurgeryRecordVoResponse preSurgeryRecordVoResponse = null;
        try {
            WardsRequest request = JsonUtils.parseObject(data, WardsRequest.class);

            if (StringUtils.isBlank(request.getHospitalCode())
                    || StringUtils.isBlank(request.getRecordId())) {
                response.setResultCodeAndMessage("1002", "数据校验失败 hospitalCode,record_id 不能为空！");
                return response;
            }

            PreSurgeryRecordVo requestHis = new PreSurgeryRecordVo();
            requestHis.setHospitalCode(request.getHospitalCode());
            requestHis.setRecordId(request.getRecordId());
            logger.info("移动查房 getWardsPreSurgeryRecord 请求调度中心入参 requestHis={}", new Object[]{JsonUtils.toJsonString(requestHis)});
            ResCommon<PreSurgeryRecordVoResponse> hisResponse = HisifaceService.getHisifaceClient().getPreSurgeryRecord(requestHis);
            logger.info("移动查房 getWardsPreSurgeryRecord 调度中心出参 hisResponse={}", new Object[]{JsonUtils.toJsonString(hisResponse)});

            if (!ResCommon.SUCCESS_CODE.equals(hisResponse.getResultCode())) {
                response.setResultCodeAndMessage(FAIL_CODE, hisResponse.getResultMessage());
            } else {
                preSurgeryRecordVoResponse = hisResponse.getResult();
                if (preSurgeryRecordVoResponse != null) {
                    response.setResultCodeAndMessageAndResult("0", "成功", preSurgeryRecordVoResponse);
                } else {
                    response.setResultCodeAndMessage(NO_DATA_CODE, NO_DATA_MSG);
                }
            }

        } catch (Exception e) {
            logger.info("移动查房 getWardsHospitalReport errMsg={}", e);
            response.setResultCodeAndMessage("1999", "系统异常 ：" + e.getMessage());
        }
        logger.info("移动查房 getWardsPreSurgeryRecord 返回 response={}", new Object[]{JsonUtils.toJsonString(response)});

        return response;
    }


      /*
       获取术前小结
     */

    public ResponseObject getWardsOutHospitalRecord(String data) {
        logger.info("移动查房 getWardsOutHospitalRecord 请求原始入参 data={}", data);
        ResponseObject response = new ResponseObject();
        OutHospitalRecordVoResponse outHospitalRecordVoResponse = null;
        try {
            WardsRequest request = JsonUtils.parseObject(data, WardsRequest.class);

            if (StringUtils.isBlank(request.getHospitalCode())
                    || StringUtils.isBlank(request.getRecordId())) {
                response.setResultCodeAndMessage("1002", "数据校验失败 hospitalCode,record_id 不能为空！");
                return response;
            }
            OutHospitalRecordVo requestHis = new OutHospitalRecordVo();
            requestHis.setHospitalCode(request.getHospitalCode());
            requestHis.setRecordId(request.getRecordId());
            logger.info("移动查房 getWardsOutHospitalRecord 请求调度中心入参 requestHis={}", new Object[]{JsonUtils.toJsonString(requestHis)});
            ResCommon<OutHospitalRecordVoResponse> hisResponse = HisifaceService.getHisifaceClient().getOutHospitalRecord(requestHis);
            logger.info("移动查房 getWardsOutHospitalRecord 调度中心出参 hisResponse={}", new Object[]{JsonUtils.toJsonString(hisResponse)});

            if (!ResCommon.SUCCESS_CODE.equals(hisResponse.getResultCode())) {
                response.setResultCodeAndMessage(FAIL_CODE, hisResponse.getResultMessage());
            } else {
                outHospitalRecordVoResponse = hisResponse.getResult();
                if (outHospitalRecordVoResponse != null) {
                    response.setResultCodeAndMessageAndResult("0", "成功", outHospitalRecordVoResponse);
                } else {
                    response.setResultCodeAndMessage(NO_DATA_CODE, NO_DATA_MSG);
                }
            }

        } catch (Exception e) {
            logger.info("移动查房 getWardsOutHospitalRecord 异常errMsg ={}", e);
            response.setResultCodeAndMessage("1999", "系统异常 ：" + e.getMessage());
        }
        logger.info("移动查房 getWardsOutHospitalRecord 返回 response={}", new Object[]{JsonUtils.toJsonString(response)});
        return response;
    }

     /*
       获取院长日报
     */

    public ResponseObject getWardsHospitalReport(String data) {
        logger.info("移动查房 getWardsHospitalReport 请求原始入参 data ={}", data);
        ResponseObject response = new ResponseObject();
        try {
            WardsRequest request = JsonUtils.parseObject(data, WardsRequest.class);

            if (StringUtils.isBlank(request.getHospitalCode())
                    || StringUtils.isBlank(request.getBeginDate()) || StringUtils.isBlank(request.getEndDate())) {
                response.setResultCodeAndMessage("1002", "数据校验失败 hospitalCode,beginDate,endDate不能为空！");
                return response;
            }
            HospitalReportVo requestHis = new HospitalReportVo();
            requestHis.setDeptCode(request.getDeptCode());
            requestHis.setHospitalCode(request.getHospitalCode());
            requestHis.setBeginDate(request.getBeginDate());
            requestHis.setEndDate(request.getEndDate());
            logger.info("移动查房 getWardsHospitalReport 请求调度中心入参 requestHis ={}", new Object[]{JsonUtils.toJsonString(requestHis)});
            ResCommon<HospitalReportVoResponse> hisResponse = HisifaceService.getHisifaceClient().getHospitalReport(requestHis);
            logger.info("移动查房 getWardsHospitalReport 调度中心出参 hisResponse ={}", new Object[]{JsonUtils.toJsonString(hisResponse)});
            if (!ResCommon.SUCCESS_CODE.equals(hisResponse.getResultCode())) {
                response.setResultCodeAndMessage(FAIL_CODE, hisResponse.getResultMessage());
            } else {
                if (hisResponse.getResult() != null) {
                    response.setResultCodeAndMessageAndResult("0", "成功", hisResponse.getResult());
                } else {
                    response.setResultCodeAndMessage(NO_DATA_CODE, NO_DATA_MSG);
                }
            }

        } catch (Exception e) {
            logger.info("移动查房 getWardsHospitalReport errMsg={}", e);
            response.setResultCodeAndMessage("1999", "系统异常 ：" + e.getMessage());
        }
        logger.info("移动查房 getWardsHospitalReport 返回 response ={}", new Object[]{JsonUtils.toJsonString(response)});

        return response;
    }

    public ResponseObject checkWardsVerificationCode(String data) {
        ResponseObject response = new ResponseObject();
        try {
            WardsBindMobileRequest request = JsonUtils.parseObject(data, WardsBindMobileRequest.class);

            if (StringUtils.isBlank(request.getMobile()) || StringUtils.isBlank(request.getVerificationCode())) {
                response.setResultCodeAndMessage("1002", "参数缺失请校验");
                return response;
            }
            String verificationCode = CacheService.getGlobalKey("base", "verification_code", request.getMobile());
            logger.info("用户端验证码登录接口, 缓存中获取验证码为：" + verificationCode);
            if (StringUtils.isNotBlank(verificationCode) && verificationCode.trim().equalsIgnoreCase(request.getVerificationCode().trim())) {
                response.setResultCodeAndMessage("0", "验证码一致");
            } else {
                response.setResultCodeAndMessage("1002", "验证码错误");
            }
        } catch (Exception e) {
            logger.error("校验验证码异常errMsg ={}", e);
            response.setResultCodeAndMessage("1002", "验证码错误");
        }
        return response;
    }

    public ResponseObject checkWardsPassword(String data) {
        ResponseObject response = new ResponseObject();
        try {
            WardsBindMobileRequest request = JsonUtils.parseObject(data, WardsBindMobileRequest.class);

            if (StringUtils.isBlank(request.getMobile()) || StringUtils.isBlank(request.getPassword())) {
                response.setResultCodeAndMessage("1002", "参数缺失请校验");
                return response;
            }
            Doctor queryDoctor = new Doctor();
            queryDoctor.setMobile(request.getMobile());
            List<Doctor> doctors = doctorDao.select(queryDoctor);
            if (CollectionUtils.isNotEmpty(doctors)) {
                Doctor doctor = doctors.get(0);
                if (StringUtils.equalsIgnoreCase(doctor.getPassword(), request.getPassword())) {
                    response.setResultCodeAndMessage("0", "密码一致");
                } else {
                    response.setResultCodeAndMessage("1002", "密码错误,请重新输入");
                }
            } else {
                response.setResultCodeAndMessage("1002", "密码错误,请重新输入");
            }
        } catch (Exception e) {
            logger.error("校验验证码异常errMsg ={}", e);
            response.setResultCodeAndMessage("1002", "密码错误,请重新输入");
        }
        return response;
    }


    public ResponseObject resetWardsPassword(String data) {
        logger.info("移动查房更新医生信息入参data={}", data);
        ResponseObject response = new ResponseObject();
        try {
            WardsBindMobileRequest request = JsonUtils.parseObject(data, WardsBindMobileRequest.class);
            if (StringUtils.isBlank(request.getMobile()) || StringUtils.isBlank(request.getPassword())) {
                response.setResultCodeAndMessage("1002", "参数缺失请校验");
                return response;
            }

            Doctor queryDoctor = new Doctor();
            queryDoctor.setMobile(request.getMobile());
            List<Doctor> doctors = doctorDao.select(queryDoctor);
            if (CollectionUtils.isNotEmpty(doctors)) {
                for (Doctor doctor : doctors) {
                    doctor.setPassword(request.getPassword());
                    doctorDao.update(doctor);
                }
                response.setResultCodeAndMessage("0", "重置密码成功！");
            } else {
                response.setResultCodeAndMessage("1002", "重置密码失败！");
            }
            return response;
        } catch (Exception e) {
            logger.error("移动查房更新医生信息异常 err={}", e);
            response.setResultCodeAndMessage("1999", "更新医生信息异常");
            return response;
        }
    }

    /**
     * 校验手机号码是否已经被绑定
     *
     * @param data
     * @return
     */
    public ResponseObject checkWardsMobileHasBinded(String data) {
        logger.info("手机号是否已经被绑定信息入参data={}", data);
        ResponseObject response = new ResponseObject();
        Map<String, String> request = JsonUtils.parseObject(data, Map.class);
        String mobile = request.get("mobile");
        try {
            if (StringUtils.isBlank(mobile)) {
                response.setResultCodeAndMessage("1002", "入参缺失，请检查");
                return response;
            }
            Doctor queryDoctor = new Doctor();
            queryDoctor.setMobile(mobile);
            List<Doctor> doctors = doctorDao.select(queryDoctor);
            Map<String, Object> resultMap = new HashMap<>();
            if (CollectionUtils.isEmpty(doctors)) {
                resultMap.put("is_binded", 0);
            } else {
                resultMap.put("is_binded", 1);
            }
            response.setResultCodeAndMessageAndResult("0", "成功", resultMap);
            logger.info("手机号是否已经被绑定信息出参response={}", JsonUtils.toJsonString(response));
            return response;
        } catch (Exception e) {
            logger.error("手机号是否已经被绑定 err={}", e);
            response.setResultCodeAndMessage("1999", "查询手机号是否已经被绑定系统异常");
            return response;
        }
    }


    /**
     * 将手机号码更医生工号绑定
     *
     * @param data
     * @return
     */
    public ResponseObject bindWardsMobile(String data) {
        logger.info("将手机号码更医生工号绑定data={}", data);
        ResponseObject response = new ResponseObject();
        try {
            WardsBindMobileRequest request = JsonUtils.parseObject(data, WardsBindMobileRequest.class);
            if (StringUtils.isBlank(request.getMobile()) || StringUtils.isBlank(request.getVerificationCode()) || StringUtils.isBlank(request.getId())) {
                response.setResultCodeAndMessage("1002", "参数缺失请校验");
                return response;
            }
            String verificationCode = CacheService.getGlobalKey("base", "verification_code", request.getMobile());
            logger.info("用户端验证码登录接口, 缓存中获取验证码为：" + verificationCode);
            if (StringUtils.isNotBlank(verificationCode)
                    && verificationCode.trim().equalsIgnoreCase(request.getVerificationCode().trim())) {
                Doctor updateDoctor = new Doctor();
                updateDoctor.setMobile(request.getMobile());
                updateDoctor.setId(request.getId());
                updateDoctor.setIsRemindAgain(1);
                doctorDao.update(updateDoctor);
                response.setResultCodeAndMessage("0", "绑定手机号成功！");
            } else {
                response.setResultCodeAndMessage("1002", "验证码有误！");
            }
            return response;
        } catch (Exception e) {
            response.setResultCodeAndMessage("1999", "绑定手机号异常");
            return response;
        }
    }


    /**
     * 获取登录短信验证码 yyt.base.user.verification.code.get
     *
     * @param data
     * @return
     */
    public ResponseObject sendWardsVerificationCode(String data) {
        logger.info("获取登录验证码接口, 入参data=" + data);
        ResponseObject response = new ResponseObject();

        WardsBindMobileRequest loginUserVo = JsonUtils.parseObject(data, WardsBindMobileRequest.class);

        if (StringUtils.isBlank(loginUserVo.getMobile())) {
            logger.info("获取登录验证码接口 request ={}", JsonUtils.toJsonString(loginUserVo));
            response.setResultCodeAndMessage("1001", "参数不能为空");
            return response;
        }

        // 发送短信
        String code = String.valueOf(Math.abs(PKGenerator.generateId().hashCode()));
        int i = code.length();
        if (i < 6) {
            code += "000000";
        }
        code = code.substring(0, 6);
        String msgStr = "{\"user_type\":\"5\",\"to_user\":\"" + loginUserVo.getMobile()
                + "\",\"msg_type\":1,\"msg_content\":{\"code\":\"" + code + "\"}}";
        MessageService.callUnderlineFromInternal("", "yyt.message.msg.sms.send", msgStr);

        Response cacheResponse = CacheService.setGlobalKey("base", "verification_code", loginUserVo.getMobile(), code, 120);

        logger.info("获取登录验证码接口, 生成验证码为：" + code + " -- CacheResponse:" + cacheResponse.getResultCode() + "; " + cacheResponse.getResultMessage());

        return response;
    }


    /**
     * 是否需要在提示绑定手机号
     *
     * @param data
     * @return
     */
    public ResponseObject updateWardsIsNeedRemindAgain(String data) {
        logger.info("是否需要在提示绑定手机号入参={}", data);
        ResponseObject response = new ResponseObject();
        try {
            WardsBindMobileRequest request = JsonUtils.parseObject(data, WardsBindMobileRequest.class);
            if (request.getIsRemindAgain() == null || StringUtils.isBlank(request.getId())) {
                response.setResultCodeAndMessage("1002", "参数缺失请校验");
                return response;
            }
            Doctor updateDoctor = new Doctor();
            updateDoctor.setId(request.getId());
            updateDoctor.setIsRemindAgain(request.getIsRemindAgain());
            doctorDao.update(updateDoctor);
            response.setResultCodeAndMessage("0", "成功！");
            return response;
        } catch (Exception e) {
            response.setResultCodeAndMessage("1999", "失败");
            return response;
        }
    }


}
